package allwe.controller;

import allwe.pojo.Player;
import allwe.service.PlayerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class PlayerController {
    @Autowired
    private PlayerService playerService;

    @GetMapping("addPlayer")
    public String addPlayer(Player player){
        //保存数据
        int a = playerService.addPlayer(player);

        //跳转到信息展示页
        return "redirects:/showPlayer.jsp";
    }


    @ResponseBody
    @GetMapping("getAllPlayer")
    public List<Player> getAllPlayer(){
        return playerService.getAllPlayer();
    }
}
